﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TimberSmart.Data.Contracts;
using TimberSmart.Data.Repositories;
using TimberSmart.Model;

namespace TimberSmart.Data.Repositories
{
    public class RepositoryFactoryCollection : Dictionary<Type, Func<DbContext, object>>
    {
        private static RepositoryFactoryCollection _defaultInstance;
        public static RepositoryFactoryCollection DefaultInstance
        {
            get
            {
                if (_defaultInstance == null)
                    _defaultInstance = CreateFactories();

                return _defaultInstance;
            }
        }

        private static RepositoryFactoryCollection CreateFactories()
        {
            RepositoryFactoryCollection factories = new RepositoryFactoryCollection();

            factories.Add(typeof(IUserRepository), context => new UserRepository(context));

            return factories;
        }
    }
}
